/** 
 * ================================================================================
 * 		Project		: Kompas Bola
 * 		File		: ListKlasemenAdapter.java
 * 		Description	: List Adapter from Klasemen
 * 		Called		: MainActivity.java
 * ================================================================================
 * */
package com.kompas.bola.application.adapter;

import java.util.List;
import com.kompas.bola.application.R;
import com.kompas.bola.application.model.Content;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListKlasemenAdapter extends BaseAdapter  {
	/** =========================================================================== */   
	private Activity activity;
	private List<Content> data;
	private static LayoutInflater inflater = null;
	/** =========================================================================== */   
	public ListKlasemenAdapter(Activity a, List<Content> d) {
		activity 					= a;
		data 						= d;
		inflater 					= (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
	/** =========================================================================== */   
	public int getCount() {
		return data.size();
	}
	/** =========================================================================== */   
	public Object getItem(int position) {
		return position;
	}
	/** =========================================================================== */   
	public long getItemId(int position) {
		return position;
	}
	/** =========================================================================== */   
	public View getView(int position, View convertView, ViewGroup parent) {
		View vi 					= convertView;
		
		vi 							= inflater.inflate(R.layout.list_klasemen, null);	
		
		if(position % 2 == 0){
			vi 						= inflater.inflate(R.layout.list_klasemen_next, null);
		}
		
		TextView tim				= (TextView) vi.findViewById(R.id.tim); // tim
		/*TextView play 				= (TextView) vi.findViewById(R.id.play); // play*/
		TextView win 				= (TextView) vi.findViewById(R.id.win); // win
		TextView draw 				= (TextView) vi.findViewById(R.id.draw); // draw
		TextView lose 				= (TextView) vi.findViewById(R.id.lose); // lose
		TextView point 				= (TextView) vi.findViewById(R.id.point); // point
        
        Content bola				= new Content();
        bola 						= data.get(position);

        tim.setText(bola.getKEY_TIM());
        /*play.setText(bola.getKEY_PLAY());*/
        win.setText(bola.getKEY_WIN());
        draw.setText(bola.getKEY_DRAW());
        lose.setText(bola.getKEY_LOSE());
        point.setText(bola.getKEY_POINT());
		
		return vi;
	}
	/** =========================================================================== */   
}
